package com.fita.admin.web.controller.order;

import com.demo2do.core.entity.page.Page;
import com.demo2do.core.entity.result.HttpResult;
import com.demo2do.core.web.interceptor.MenuSetting;
import com.demo2do.core.web.resolver.Preloading;
import com.demo2do.core.web.utils.WebUtils;
import com.fita.admin.entity.search.order.ReverseOrderSearch;
import com.fita.admin.entity.security.Login;
import com.fita.admin.service.agent.AgentAuditService;
import com.fita.admin.service.agent.AgentCompanyService;
import com.fita.admin.service.agent.AgentService;
import com.fita.admin.service.data.PaymentRequestService;
import com.fita.admin.service.order.EnquiryService;
import com.fita.admin.service.order.MarkPayRecordService;
import com.fita.admin.service.order.ReverseOrderService;
import com.fita.admin.web.resolver.Secure;
import com.fita.entity.agent.AgentCompany;
import com.fita.entity.order.MarkPayRecord;
import com.fita.entity.order.OrderPayType;
import com.fita.admin.entity.PaymentContext;
import com.fita.entity.order.reverse.ReverseOrder;
import com.fita.entity.order.reverse.ReverseOrderStatus;
import com.fita.entity.order.reverse.ReverseOrderType;
import com.fita.entity.order.reverse.aviation.AviationRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @description:
 * @author: 11200
 * @date: 2019/8/22
 */
@Controller
@RequestMapping(path = "/reverse-orders")
@MenuSetting("menu-order")
public class ReverseOrderController {

    private static final Logger logger = LoggerFactory.getLogger(ReverseOrderController.class);

    @Autowired
    private ReverseOrderService reverseOrderService;

    @Autowired
    private AgentCompanyService agentCompanyService;

    @Autowired
    private EnquiryService enquiryService;

    @Autowired
    private AgentAuditService agentAuditService;

    @Autowired
    private AgentService agentService;

    @Autowired
    private PaymentRequestService paymentRequestService;

    @Autowired
    private MarkPayRecordService markPayRecordService;


    @Value("#{config['wechat.host']}")
    private String wechatHost;

    @GetMapping(path = "/search")
    public ModelAndView search(ReverseOrderStatus status, ReverseOrderType type){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-search");

        modelAndView.addObject("status", status);

        modelAndView.addObject("type", type);

        modelAndView.addObject("statusEnums", ReverseOrderStatus.values());

        return modelAndView;
    }

    /**
     * 航空订单list
     *
     * @return
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    @MenuSetting("submenu-{type.toString().toLowerCase()}-reverse-order-list")
    public ModelAndView list(@RequestParam(defaultValue = "EDITING") ReverseOrderStatus status,
                             ReverseOrderSearch search,
                             Page page,
                             HttpServletRequest request) {

        ModelAndView modelAndView = new ModelAndView("order/reverse/order-list");

        search.setStatus(status);

        int count = reverseOrderService.count(search);

        if (count > 0){

            List<ReverseOrder> reverseOrders = reverseOrderService.search(ReverseOrder.class, search, page.with(count));

            modelAndView.addObject("reverseOrders", reverseOrders);
        }
        modelAndView.addObject("queryString", WebUtils.extractQueryString(request, "filter", "page"));

        modelAndView.addObject("status", search.getStatus());

        modelAndView.addObject("type", search.getType());

        modelAndView.addObject("needPay", search.isNeedPay());

        return modelAndView;
    }

    /**
     * 详情
     *
     * @return
     */
    @RequestMapping(value = "/{orderId}", method = RequestMethod.GET)
    @MenuSetting("submenu-{type.toString().toLowerCase()}-reverse-order-list")
    public ModelAndView view(@PathVariable Long orderId) {

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-view");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        modelAndView.addObject("type", reverseOrder.getType());

        modelAndView.addObject("status", reverseOrder.getStatus());

        List<Object[]> paymentContexts = reverseOrderService.listPaymentContext(reverseOrder.getCode());

        modelAndView.addObject("paymentContexts", paymentContexts);

        List<MarkPayRecord> markPayRecords = markPayRecordService.listByOrderCode(reverseOrder.getCode());

        modelAndView.addObject("markPayRecords", markPayRecords);

        return modelAndView;
    }

    /**
     * 修改价格
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/{orderId}/edit-price", method = RequestMethod.GET)
    @MenuSetting("submenu-{type.toString().toLowerCase()}-reverse-order-list")
    public ModelAndView editPrice(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-edit-price");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        modelAndView.addObject("type", reverseOrder.getType());

        modelAndView.addObject("isEdit", true);

        return modelAndView;
    }

    /**
     * 修改价格
     * @param price
     * @param costPrice
     * @param reverseOrderId
     * @return
     */
    @PatchMapping(path = "/{reverseOrderId}/edit-price", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onEditPrice(@RequestParam BigDecimal price,
                                  @RequestParam BigDecimal costPrice,
                                  @PathVariable Long reverseOrderId,
                                  @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date lastPayTime){
        try {
            reverseOrderService.editPrice(reverseOrderId, price, costPrice, lastPayTime);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("#onEditPrice() error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 修改预定
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/{orderId}/edit-book", method = RequestMethod.GET)
    @MenuSetting("submenu-{type.toString().toLowerCase()}-reverse-order-list")
    public ModelAndView editBook(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-edit-book");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        modelAndView.addObject("type", reverseOrder.getType());

        return modelAndView;
    }

    /**
     * 修改预定
     * @param reverseOrderId
     * @return
     */
    @PatchMapping(path = "/{reverseOrderId}/edit", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onEdit(@Preloading("reverseOrderId") ReverseOrder reverseOrder,
                                 @PathVariable Long reverseOrderId){
        try {
            reverseOrderService.editBook(reverseOrderId, reverseOrder);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("#onEdit() error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 发送客户
     * @return
     */
    @GetMapping(path = "/{reverseOrderId}/send-to-client")
    public ModelAndView sendToClient(@PathVariable Long reverseOrderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-send-to-client");

        List<AgentCompany> primaryAgentCompanies = agentCompanyService.listPrimaryAgentCompany();

        modelAndView.addObject("primaryAgentCompanies", primaryAgentCompanies);

        modelAndView.addObject("reverseOrderId", reverseOrderId);

        return modelAndView;
    }

    /**
     * 发送客户
     * @return
     */
    @PostMapping(path = "/{reverseOrderId}/send-to-client", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onSendToClient(@PathVariable Long reverseOrderId){

        try {
            reverseOrderService.sendToClient(reverseOrderId);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("#onSendToClient() error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 发送短信给客户
     * @return
     */
    @GetMapping(path = "/{reverseOrderId}/send-message-to-client")
    public ModelAndView sendMessageToClient(@PathVariable Long reverseOrderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-send-message-to-client");

        modelAndView.addObject("reverseOrderId", reverseOrderId);

        String url = wechatHost + "/reverse-orders/" + reverseOrderId;

        modelAndView.addObject("url", url);

        return modelAndView;
    }


    /**
     * 发送短信给客户
     * @param reverseOrderId
     * @return
     */
    @PostMapping(path = "/{reverseOrderId}/send-message-to-client", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onSendMessageToClient(@PathVariable Long reverseOrderId){

        try {
            reverseOrderService.sendMessageToClient(reverseOrderId);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("#onSendToClient() error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 标记支付
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/{orderId}/mark-pay", method = RequestMethod.GET)
    public ModelAndView markPay(@PathVariable Long orderId) {

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-mark-pay");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 标记支付
     * @param orderId
     * @param login
     * @return
     */
    @PostMapping(path = "/{orderId}/mark-pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onMarkPay(@PathVariable Long orderId,
                                @RequestParam OrderPayType payType,
                                String payPic,
                                @RequestParam String payCode,
                                @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date payTime,
                                @RequestParam BigDecimal price,
                                @Secure Login login){
        try {
            reverseOrderService.markPay(orderId, payCode, payTime, price, login, payType, payPic);

            ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

            if(reverseOrder.isNeedPay()){
                return new HttpResult().success().message("还需支付：" + reverseOrder.getPrettyNeedPayPrice());
            }
            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("#onMarkPay() error，[{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 取消订单
     * @param orderId
     * @return
     */
    @GetMapping(path = "/{orderId}/cancel")
    public ModelAndView cancel(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-cancel");

        modelAndView.addObject("orderId", orderId);

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 取消订单
     * @param orderId
     * @return
     */
    @PatchMapping(path = "/{orderId}/cancel", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onCancel(@PathVariable Long orderId, BigDecimal refundPrice){

        try {
            reverseOrderService.cancel(orderId, refundPrice);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("reverse order cancel fail [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }

    }

    /**
     * 标记出票
     * @param orderId
     * @return
     */
    @GetMapping(path = "/{orderId}/mark-ticket")
    public ModelAndView markTicket(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-mark-ticket");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 标记出票
     * @param orderId
     * @return
     */
    @PostMapping(path = "/{orderId}/mark-ticket", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onMarkTicket(@PathVariable Long orderId,
                                   @RequestParam String orderCode,
                                   @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date ticketTime){
        try {
            reverseOrderService.markTicket(orderId, orderCode, ticketTime);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("mark ticket error. [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 删除
     * @return
     */
    @GetMapping(path = "/{orderId}/delete")
    public ModelAndView delete(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-delete");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 删除
     * @param orderId
     * @return
     */
    @PatchMapping(path = "/{orderId}/delete", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onDelete(@PathVariable Long orderId){

        try {
            reverseOrderService.delete(orderId);

            return new HttpResult().success();
        } catch (Exception e) {

            logger.error("delete reverse order error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 标记核销
     * @param orderId
     * @return
     */
    @GetMapping(path = "/{orderId}/mark-consumed")
    public ModelAndView markConsumed(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-mark-consumed");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 标记核销
     * @return
     */
    @PostMapping(path = "/{orderId}/mark-consumed", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onMarkConsumed(@PathVariable Long orderId){

        try {
            reverseOrderService.markConsumed(orderId);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("mark reverse order error");

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 标记退款
     * @return
     */
    @GetMapping(path = "/{orderId}/mark-refund")
    public ModelAndView markRefund(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-mark-refund");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 标记退款
     * @param orderId
     * @return
     */
    @PostMapping(path = "/{orderId}/mark-refund", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onMarkRefund(@PathVariable Long orderId/*, @RequestParam String refundCode*/){

        try {
            reverseOrderService.markRefund(orderId, null);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("mark reverse order error");

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }

    /**
     * 跳过询价单直接创建反向订单
     * @return
     */
    @GetMapping(path = "/create")
    public ModelAndView create(@RequestParam(defaultValue = "AVIATION") ReverseOrderType orderType, @Secure Login login){

/*        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-direct-create");

        ReverseOrderType[] reverseOrderTypes = ReverseOrderType.values();

        modelAndView.addObject("reverseOrderTypes", reverseOrderTypes);

        modelAndView.addObject("orderType", orderType);*/


        reverseOrderService.create(orderType, login.getId());

        ModelAndView modelAndView = new ModelAndView("redirect:/reverse-orders?type=" + orderType);

        return modelAndView;
    }

/*    *//**
     * 跳过询价单直接创建反向订单
     * @param reverseOrderType
     * @param login
     * @return
     *//*
    @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onCreate(@RequestParam ReverseOrderType reverseOrderType,
                               @Secure Login login){

        try {
            reverseOrderService.create(reverseOrderType, login.getId());

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("direct create reverse order error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }*/

    /**
     * 修改客户信息
     * @return
     */
    @GetMapping(path = "/{orderId}/edit-custom-info")
    public ModelAndView editCustomInfo(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-edit-custom-info");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }


    /**
     * 修改订单信息
     * @return
     */
    @GetMapping(path = "/{orderId}/edit-order-info")
    public ModelAndView editOrderInfo(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-edit-order-info");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        List<AgentCompany> primaryAgentCompany = agentCompanyService.listPrimaryAgentCompany();

        modelAndView.addObject("primaryAgentCompany", primaryAgentCompany);

        return modelAndView;
    }

    @PatchMapping(path = "/{orderId}/edit-order-info", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onCreate(@PathVariable Long orderId, @RequestParam Long primaryAgentCompanyId){

        try {
            reverseOrderService.editOrderInfo(orderId, primaryAgentCompanyId);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("direct create reverse order error [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }


    /**
     * 修改客户不可见备注
     * @return
     */
    @GetMapping(path = "/{orderId}/edit-order-remark")
    public ModelAndView editRemark(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-edit-order-remark");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 修改航班乘机人
     * @param orderId
     * @param passportPicCode
     * @return
     */
    @GetMapping(path = "/{orderId}/edit-aviation-user-info")
    public ModelAndView editAviationUserInfo(@PathVariable Long orderId,
                                             @RequestParam String passportPicCode){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-edit-aviation-user-info");

        AviationRequest.AviationUserInfo aviationUserInfo = reverseOrderService.loadAviationUserInfo(orderId, passportPicCode);

        modelAndView.addObject("aviationUserInfo", aviationUserInfo);

        modelAndView.addObject("orderId", orderId);

        return modelAndView;
    }

    /**
     * 修改航班乘机人
     * @param orderId
     * @param aviationUserInfo
     * @return
     */
    @PatchMapping(path = "/{orderId}/edit-aviation-user-info", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onEditAviationUserInfo(@PathVariable Long orderId,
                                             AviationRequest.AviationUserInfo aviationUserInfo){

        try {
            reverseOrderService.editAviationUserInfo(orderId, aviationUserInfo);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("edit aviation user info error [{}]", e);

            return new HttpResult().fail("500");
        }
    }

    /**
     * 删除乘机人
     * @param orderId
     * @return
     */
    @GetMapping(path = "/{orderId}/delete-aviation-user-info")
    public ModelAndView deleteAviationUserInfo(@PathVariable Long orderId,
                                               @RequestParam String passportPicCode){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-delete-aviation-user-info");

        modelAndView.addObject("orderId", orderId);

        modelAndView.addObject("passportPicCode", passportPicCode);

        return modelAndView;
    }


    /**
     * 删除航班乘机人
     * @param orderId
     * @return
     */
    @PostMapping(path = "/{orderId}/delete-aviation-user-info", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onDeleteAviationUserInfo(@PathVariable Long orderId,
                                               @RequestParam String passportPicCode){
        try {
            reverseOrderService.deleteAviationUserInfo(orderId, passportPicCode);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("edit aviation user info error [{}]", e);

            return new HttpResult().fail("500");
        }
    }



    /**
     * 添加航班乘机人
     * @param orderId
     * @return
     */
    @GetMapping(path = "/{orderId}/add-aviation-user-info")
    public ModelAndView addAviationUserInfo(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-add-aviation-user-info");

        modelAndView.addObject("orderId", orderId);

        return modelAndView;
    }

    /**
     * 添加航班乘机人
     * @param orderId
     * @param aviationUserInfo
     * @return
     */
    @PostMapping(path = "/{orderId}/add-aviation-user-info", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onAddAviationUserInfo(@PathVariable Long orderId,
                                             AviationRequest.AviationUserInfo aviationUserInfo){
        try {
            reverseOrderService.addAviationUserInfo(orderId, aviationUserInfo);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("edit aviation user info error [{}]", e);

            return new HttpResult().fail("500");
        }
    }

    /**
     * 改价
     * @param orderId
     * @return
     */
    @GetMapping(path = "/{orderId}/reset-price")
    public ModelAndView resetPrice(@PathVariable Long orderId){

        ModelAndView modelAndView = new ModelAndView("order/reverse/reverse-order-reset-price");

        ReverseOrder reverseOrder = reverseOrderService.load(ReverseOrder.class, orderId);

        modelAndView.addObject("reverseOrder", reverseOrder);

        return modelAndView;
    }

    /**
     * 改价
     * @return
     */
    @PatchMapping(path = "/{orderId}/reset-price", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public HttpResult onRestPrice(@PathVariable Long orderId,
                                  @RequestParam BigDecimal resetPrice,
                                  @RequestParam BigDecimal costPrice,
                                  @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date lastPayTime){
        try {
            reverseOrderService.resetPrice(orderId, resetPrice, costPrice, lastPayTime);

            return new HttpResult().success();

        } catch (Exception e) {

            logger.error("raise price fail, [{}]", e);

            return new HttpResult().fail("500").message(e.getMessage());
        }
    }



}
